<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<form:form commandName="target" cssClass="form-horizontal" role="form">
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">指标名称</label>
        <div class="col-sm-4">
            <input type="text" name="indexName" class="form-control" required>
        </div>
        <label class="col-sm-2 control-label no-padding-right">指标年份</label>
        <div class="col-sm-4">
            <input type="text" autocomplete='off' name="datetime" class="form-control date-picker" required>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="parentIndexId_select">父级指标</label>
        <div class="col-sm-4">
            <select name="parentIndexId" id = "parentIndexId_select" class="form-control">
                <option value="">无</option>
                <c:forEach items="${indexInfoEntityList}" var="indexInfoEntityList">
                    <option value="${indexInfoEntityList.sysId}">${indexInfoEntityList.indexName}</option>
                </c:forEach>
            </select>
        </div>
        <label class="col-sm-2 control-label no-padding-right">指标等级</label>
        <div class="col-sm-4">
            <input type="text" id="indexLevel_add" name="indexLevel" class="form-control" readonly>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">指标时间类型</label>
        <div class="col-sm-4">
            <select name="dateUnit" class="form-control" required>
                <option value="">请选择</option>
                <option value="1">月度指标</option>
                <option value="2">季度指标</option>
                <option value="3">年度指标</option>
            </select>
        </div>
        <label class="col-sm-2 control-label no-padding-right">分管领导</label>
        <div class="col-sm-4">
            <input type="text" autocomplete='off' name="leader" class="form-control" required>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right" for="leadDept_select">牵头单位</label>
        <div class="col-sm-4">
            <select name="leadDept" id="leadDept_select" class="form-control" required>
                <option value="">请选择</option>
                <c:forEach items="${countyUnitList}" var="countyUnitList">
                    <option value="${countyUnitList.deptCode}">${countyUnitList.deptName}</option>
                </c:forEach>
            </select>
        </div>
        <label class="col-sm-2 control-label no-padding-right">责任单位</label>
        <div class="col-sm-4">
            <input type="text" autocomplete='off' name="respDept" class="form-control">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label no-padding-right">乡镇</label>
        <div class="col-sm-4">
            <select name="town" class="form-control">
                <option value="">请选择</option>
                <c:forEach items="${townUnitList}" var="townUnitList">
                    <option value="${townUnitList.deptCode}">${townUnitList.deptName}</option>
                </c:forEach>
            </select>
        </div>
        <label class="col-sm-2 control-label no-padding-right">企业名称</label>
        <div class="col-sm-4">
            <select name="enterprise" class="form-control">
                <option value="">请选择</option>
                <c:forEach items="${enterpriseEntities}" var="enterpriseEntities">
                    <option value="${enterpriseEntities.sysId}">${enterpriseEntities.enterpriseName}</option>
                </c:forEach>
            </select>
        </div>
    </div>
    <%--任务id  隐藏--%>
    <form:hidden path="sysId"/>
</form:form>
<script>
    $(function () {
        $("#indexLevel_add").val("1");
        $(".date-picker").datepicker({
            changeMonth: true,
            changeYear: true,
            inline: true,
            // startView: 2, maxViewMode: 1, minViewMode: 1,
            startView: 2, maxViewMode: 2, minViewMode: 2,
            format: "yyyy",
            autoclose: true,
            todayHighlight: true,
            language: 'cn'
        }).next().on(ace.click_event, function () {
            $(this).prev().focus();
        });

        $("#indexId_select").change(function () {
            var indexId = $("#indexId_select").val();
        })
    });

    $("#parentIndexId_select").change(function () {
        var indexId = $("#parentIndexId_select").val();
        $.ajax({
            url: "/web/indexTarget/queryBeanByIndexId",
            type: "POST",
            dataType: "json", //返回数据形式为json
            contentType: 'application/json;charset=UTF-8',
            data: JSON.stringify({"indexId": indexId}),
            success: function (res) {
                if (res.code == '200') {
                    //指标等级
                    var indexLevel = res.data.indexLevel;
                    $("#indexLevel_add").val(indexLevel);
                } else {
                    $("#indexLevel_add").val("1");
                    console.log("内部出错：/web/indexTarget/queryBeanByIndexId")
                }
            }
        });
    })
</script>


